package com.lengxf.mynative;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * spring native-demo
 * 参考官方文档 <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html">...</a>
 * <p>
 * 需要在本机安装 gravel vm 17
 * 且在本机安装好docker
 * 在pom文件路径下执行打包脚本 $ mvn -Pnative spring-boot:build-image
 * 会推送镜像到本地docker仓
 * <p>
 * docker 执行命令启动
 * docker run -itd --name=spring-native -p 9999:9999 -e SPRING_PROFILES_ACTIVE=native   镜像名称：版本号
 *
 * @author Lengxf
 **/
@RestController
@SpringBootApplication
public class NativeApplication {
    @Value("${a.b}")
    private String ab;

    //使用本机测试 直接启动花费3.173多点
    //使用native形式启动 花费0.082S
    //启动速度提升了 40倍
    public static void main(String[] args) {
        SpringApplication.run(NativeApplication.class, args);
    }

    @RequestMapping("/")
    String home() {
        return "Hello World!" + " " + ab;
    }
}
